import java.math.BigInteger;


public class Prog implements Node {

	//program has 2 children <decl seq> and <stmt seq>
	public String token = "<prog>";
	public Node decl_seq;
	public Node stmt_seq;
			
	public Prog(){
		//check the first token is program
		int token = PSTree.Core_TK.getToken();
		
		if(token != 1){
			System.out.println("error: expecting \"program\" token in prog");
			System.exit(1);
		}
		PSTree.Core_TK.skipToken();		
		//---------------------------------------------------------------------------------
		decl_seq = new Decl_Seq();
		//---------------------------------------------------------------------------------
		token = PSTree.Core_TK.getToken();
		if(token != 2){
			System.out.println("error: expecting \"begin\" token in prog");
			System.exit(1);
		}
		PSTree.DS = false;
		PSTree.Core_TK.skipToken();
		// parse statement sequence
		//---------------------------------------------------------------------------------
		stmt_seq = new Stmt_Seq();
		//---------------------------------------------------------------------------------
		// next token should be end
		token = PSTree.Core_TK.getToken();
		if(token != 3){
			System.out.println(token);
			System.out.println("Expecting \"end\" token after statement_seqence");
			System.exit(1);
		}
		PSTree.Core_TK.skipToken(); // skip final end
	}

	@Override
	public void print(int indent) {
		System.out.println("program");
		PSTree.DS = true;
		this.decl_seq.print(indent+1);
		PSTree.DS = false;
		System.out.println("begin");
		this.stmt_seq.print(indent+1);
		System.out.println("end");
		
	}

	
	public void execute() {
		// set flag to statement sequence
		PSTree.DS = true;
		decl_seq.intexecute();
		// stop statement sequence flag
		PSTree.DS = false;
		this.stmt_seq.intexecute();		
		
	}

	@Override
	public BigInteger intexecute() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean compexecute() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String Stringexcec() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
